package com.loveprogrammer.eternity.model.mission;

import com.loveprogrammer.eternity.factory.template.TaskTemplate;
import com.loveprogrammer.eternity.model.Hero;
import com.loveprogrammer.eternity.model.game.HeroWrapper;
import lombok.Data;

import java.io.Serializable;
import java.util.UUID;

/**
 * @version 1.0.0
 * @description: 任务定义类
 * @author: eric
 * @date: 2023-01-05 14:34
 **/
@Data
public abstract class MissionDefinition implements IMission, Serializable {

    private String taskId;
    /**
     * 进展
     */
    private Integer progress;

    /**
     * 接收事件时间
     */
    private long createTime;

    /**
     * 任务目标类型 1-杀怪 2-获取指定物品 3-和某人对话 4-孵化战兽 5-出战战兽 6-商城消费 7-赌博 8-接悬赏任务 9-
     */
    private Integer taskTargetType;

    /**任务配置表*/
    // private TaskTemplate tasktemplate;

    /**任务结束后奖励*/
    private MissionReward reward;

    public MissionDefinition(){
    }

    public MissionDefinition(String taskId, Integer progress,long createTime, Integer taskTargetType, MissionReward reward) {
        this.taskId = taskId;
        this.progress = progress;
        this.createTime = createTime;
        this.taskTargetType = taskTargetType;
        this.reward = reward;
    }

    public MissionDefinition(Integer taskTargetType, MissionReward reward) {
        this.taskId = UUID.randomUUID().toString();
        this.progress = 0;
        this.createTime = System.currentTimeMillis();
        this.taskTargetType = taskTargetType;
        this.reward = reward;
    }

    @Override
    public void update(HeroWrapper hero, MissionAction action) {
        doUpdate(hero,action);
        checkTaskComplete(hero);
    }

    protected abstract void doUpdate(HeroWrapper hero, MissionAction action);

    @Override
    public boolean checkTaskComplete(HeroWrapper hero) {
        return false;
    }

}
